Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sumor/i18n

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sumor/i18n

This is a lightweight i18n library for Node.js and the browser. You can easily use it to manage your i18n resources. And apply it to your project.

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61K
decreased by-13.12%
Maintainers
0
Weekly downloads
 
Created
Source

i18n

A Sumor Cloud Tool.
More Documentation

This is a lightweight i18n library for Node.js and the browser. You can easily use it to manage your i18n resources. And apply it to your project.

CI Test Coverage Audit

Installation

npm i @sumor/i18n --save

Prerequisites

Node.JS version

Require Node.JS version 18.x or above

require Node.JS ES module

As this package is written in ES module, please change the following code in your package.json file:

{
  "type": "module"
}

Usage

import getI18n from '@sumor/i18n'

const i18nConfig = {
  en: {
    demo: {
      hello: 'Hello',
      welcome: 'Welcome',
      greeting: 'Hello, {name}',
      test: 'Test'
    }
  },
  zh: {
    demo: {
      hello: '你好',
      welcome: '欢迎'
    }
  },
  'zh-TW': {
    demo: {
      hello: '妳好',
      greeting: '妳好, {name}'
    }
  }
}

const i18n = getI18n('zh-TW', i18nConfig)

// match zh-TW
console.log(i18n('demo.hello')) // 妳好
console.log(i18n('demo.greeting', { name: 'John' })) // 妳好, John

// match zh
console.log(i18n('demo.welcome')) // 欢迎

// match en
console.log(i18n('demo.test')) // Test

Keywords

FAQs

Package last updated on 08 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc